@echo off
echo 快速测试Ubuntu轻量级桌面环境...
echo.

REM 检查Docker是否运行
docker info >nul 2>&1
if %errorlevel% neq 0 (
    echo 错误: Docker未运行，请先启动Docker Desktop
    pause
    exit /b 1
)

echo 清理之前的容器和镜像...
docker-compose -f docker-compose.lightweight.yml down --rmi all --volumes --remove-orphans

echo 构建轻量级镜像...
docker-compose -f docker-compose.lightweight.yml build --no-cache

if %errorlevel% neq 0 (
    echo 构建失败，请检查错误信息
    pause
    exit /b 1
)

echo 启动轻量级容器...
docker-compose -f docker-compose.lightweight.yml up -d

if %errorlevel% neq 0 (
    echo 启动失败，请检查错误信息
    pause
    exit /b 1
)

echo.
echo 等待容器启动...
timeout /t 10 /nobreak >nul

echo 检查容器状态...
docker-compose -f docker-compose.lightweight.yml ps

echo.
echo 查看容器日志...
docker-compose -f docker-compose.lightweight.yml logs --tail=20

echo.
echo 轻量级桌面环境已启动！
echo.
echo 访问方式:
echo VNC: localhost:5901
echo SSH: ssh -p 2223 ubuntu@localhost
echo.
echo 测试命令:
echo 1. 查看容器状态: docker-compose -f docker-compose.lightweight.yml ps
echo 2. 进入容器: docker exec -it ubuntu-desktop-lightweight bash
echo 3. 查看桌面快捷方式: docker exec -it ubuntu-desktop-lightweight ls -la /home/ubuntu/Desktop
echo 4. 停止服务: docker-compose -f docker-compose.lightweight.yml down
echo.
pause 